﻿#include <Sys\RenderUnit\SysRenderDatagram\SOLIDRD.HPP>


#define CSolid_ClassID L"0AA6F129A4254003900D75F9C3794CB9"

using namespace CxxlMan;
using namespace Cxxl3D;

cxxlObject *cxxlFASTCALL New_CSolidRD();
cxxlPreserve2 *cxxlFASTCALL Regenera_CSolidRD(const wchar_t *ClassID);

class CSolidRD:public ISolidRD
{
  tagISolidRD_Cfg m_Cfg;

 // P2Smart_Ptr<IBasicPrimitiveRD> m_IBasicPrimitiveRD_Ptr;

  


  // 設定 IBasicPrimitiveRD 物件
  /*
  virtual void cxxlFASTCALL SetIBasicPrimitiveRD(const Smart_Ptr<IBasicPrimitiveRD> &IBasicPrimitiveRD_Arg)
  {
    csPreserve.Enter();
    m_IBasicPrimitiveRD_Ptr = IBasicPrimitiveRD_Arg;
    csPreserve.Leave();
  }


  // 取得 IBasicPrimitiveRD 物件
  Smart_Ptr<IBasicPrimitiveRD> cxxlFASTCALL GetIBasicPrimitiveRD() const
  {
    CriticalSecHandle AutoCSH(csPreserve);

    return m_IBasicPrimitiveRD_Ptr;
  }
*/
  virtual void cxxlFASTCALL SetCfg(const tagISolidRD_Cfg &Cfg)
  {
    csPreserve.Enter();
    m_Cfg = Cfg;
    csPreserve.Leave();
  }

  virtual tagISolidRD_Cfg cxxlFASTCALL GetCfg()
  {
    CriticalSecHandle AutoCSH(csPreserve);
    return m_Cfg;
  }


protected:
  // 儲存容器藉此取得要永續存取的屬性資料
  // 延伸類別須以 virtual 的形式覆寫
  // 並且須呼叫上層類別的此函數
  virtual bool cxxlFASTCALL Ref(Filter *F)
  {
    if(F != NULL && ISolidRD::Ref(F))
    {
      return true;
    }
    else
      return false;
  }

public:
  // Constructor
  CSolidRD()
    :cxxlObject(CxxlMan::Spirit_Easy),    
    cxxlPreserve2(CSolid_ClassID) // 在建構時指定 ClassID
    //m_IBasicPrimitiveRD_Ptr(NULL,this,L"BP")
  {
  }
  virtual ~CSolidRD()
  {
  }


  friend cxxlObject *cxxlFASTCALL New_CSolidRD();
  friend cxxlPreserve2 *cxxlFASTCALL Regenera_CSolidRD(const wchar_t *ClassID);
};


cxxlObject *cxxlFASTCALL New_CSolidRD()
{
  return new CSolidRD();
}

cxxlPreserve2 *cxxlFASTCALL Regenera_CSolidRD(const wchar_t *ClassID)
{
  if(wcscmp(CSolid_ClassID, ClassID) == 0)
    return new CSolidRD;
  else
    return NULL;

}
